<!DOCTYPE html>
<html>
<head th:include="cultivateWeb/header :: culHeaderCss"></head>
<style>
    .titleEaxm {
        margin-bottom: 30px;
        padding-bottom: 10px;
        border-bottom: 1px solid #999;
    }

    .title11 {
        font-weight: bold;
        font-size: 16px;
    }

    .showTrue {
        color: #005C34;
        font-weight: bold
    }

    .mar11 {
        margin: 10px 0;
        font-size: 16px;
    }
</style>
<body>
<!-- 顶部导航 -->
<header th:include="cultivateWeb/header :: header"></header>
<link type="text/css" href="/css/cultivateWeb/style/course.css" rel="stylesheet">
<div style="background-color: #f7f7f7; ">
    <div class="layui-container">
        <p style="line-height: 40px">当前位置：<a href="/cultivate/homepage">首页</a> > <a href="/cultivate/my">个人中心</a>
            > <a href="/cultivate/myClasss/myClasss">班级考试</a> > 答卷详情</p>
        <input th:value="${paperId}" type="hidden" id="paperId"/>
        <input th:value="${isSubmit}" type="hidden" id="isSubmit"/>
    </div>
    <section>
        <div class="layui-container">
            <div >
                <button class="btn btn-success" onclick="print()"> 打印试卷 </button>
            </div>
            <div style="text-align: right">
                <span class="levelBack"><a href="/cultivate/myClasss/myClasss">返回</a> </span>
            </div>
            <div id="content"></div>
        </div>
    </section>
</div>

<!-- footer ------------------------------------------------------- -->
<div class="footer" th:include="cultivateWeb/header :: footer"></div>
</body>
<script>

   // let ExamTimeStatus = '';// 0考试时间还未到 1已超过考试截止时间 2在考试时间期间
    $(function () {
        ajaxToken("/jzApi/courses/getIsSubmit", 'POST',
            {
                id: $("#paperId").val()
            }, function (res) {
                console.log("res.isSubmit:"+res.isSubmit);
                if(res.isSubmit == 1){
                    selDetail();
                }else {
                    getExamTime();
                }
            }
        );
    });

    function getExamTime() {
        ajaxToken("/jzApi/courses/getExamTime", 'POST',
            {
                id: $("#paperId").val()
            }, function (res) {
               // ExamTimeStatus = 2;
                selDetail();
            }
        )
    }
    function selDetail() {
        ajaxToken("/jzApi/courses/selClassesExamnation", 'POST',
            {
                id: $("#paperId").val(),
                type: 'answer'
            }, function (res) {
                var b = '';
                var a = '<div style="font-size: 20px; font-weight: bold;margin-bottom:40px;text-align: center;">' + res.papersName + '</div><div>';//题目
                res.answerLists.forEach(function (item, index, arr) {
                    //你选的答案
                    res.yourChoose = '';
                    var list = item.options.split(";;");
                    var b = '';
                    //判断题目类型，写入题目描述
                    //写入题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar11"><label>' + list[i] + '</label></div>'
                    }
                    if (item.type == 0) {  //单选
                        a += '<div type="' + item.type + '" class="titleEaxm" data-index="' + index + '"><div class="title11">' + parseInt(parseInt(index) + parseInt(1)) + '、（单选题）' + item.introduce + '</div>' + b;
                    }
                    //判断题目类型，写入题目描述
                    if (item.type == 2) { //判断
                        a += '<div type="' + item.type + '" class="titleEaxm" data-index="' + index + '"><div class="title11">' + parseInt(parseInt(index) + parseInt(1)) + '、（判断题）' + item.introduce + '</div>' + b;
                    }
                    if (item.type == 1) {  //多选
                        a += '<div type="' + item.type + '" class="titleEaxm" data-index="' + index + '"><div class="title11">' + parseInt(parseInt(index) + parseInt(1)) + '、（多选题）' + item.introduce + '</div>' + b;
                    }
                    if (item.type == 3) {  //填空
                        a += '<div type="' + item.type + '" class="titleEaxm" data-index="' + index + '"><div class="title11">' + parseInt(parseInt(index) + parseInt(1)) + '、（填空题）' + item.introduce + '</div>' + b;
                    }
                    if (item.type == 4) {  //问答
                        a += '<div type="' + item.type + '" class="titleEaxm" data-index="' + index + '"><div class="title11">' + parseInt(parseInt(index) + parseInt(1)) + '、（问答题:需要老师批阅）' + item.introduce + '</div>' + b;
                    }
                    a += '<div class="mar11" style="color:#ff751a">你的答案：' + item.answer + '</div>' +
                        '<div class="mar11 showTrue">正确答案：' + item.rightKey + '</div>' +
                        '<div class="mar11 showTrue">答案解析：' + item.topicAnalysis + '</div></div>';
                });
                $("#content").html(a);
            }
        )
    }
</script>

</html>